package com.mobile.check.activitys;

import android.app.Activity;
import android.content.Intent;
import android.view.View;

import butterknife.BindView;
import cn.droidlover.xdroidmvp.cache.SharedPref;
import cn.droidlover.xdroidmvp.mvp.XActivity;
import com.mobile.check.app.R;
import com.mobile.check.present.BasePresent;
import com.mobile.check.util.AppContents;
import com.mobile.check.views.MyEditText;

/**
 * 类名: InputEditActivity
 * 作者: 李学伟
 * 日期: 2020年10月14日 18:37
 * 描述:
 */
public class InputEditActivity extends XActivity<BasePresent> {
    @BindView(R.id.userTv)
    MyEditText userTv;
    @BindView(R.id.deviceTv)
    MyEditText deviceTv;
    int type;

    @Override
    public void initView() {
        super.initView();
        titleTv.setText("设置");
        rightTv.setText("确定");
        rightTv.setVisibility(View.VISIBLE);
        String userName = SharedPref.getInstance(this).getString(AppContents.USERNAME, "");
        String device = SharedPref.getInstance(this).getString(AppContents.TESTDEVICE, "");
        userTv.setValue(userName);
        deviceTv.setValue(device);
    }

    @Override
    public void onRightClick(View view) {
        super.onRightClick(view);
        String user = userTv.getValue();
        String testDevice = deviceTv.getValue();
        SharedPref.getInstance(this).putString(AppContents.USERNAME, user);
        SharedPref.getInstance(this).putString(AppContents.TESTDEVICE, testDevice);
        setResult(Activity.RESULT_OK);
        finish();
    }

    @Override
    public void getDataFromServer() {

    }

    @Override
    public int getContentViewId() {
        return R.layout.activity_inputedit;
    }

    @Override
    public void getIntentData() {
        type = getIntent().getIntExtra("type", 0);
    }

    @Override
    public BasePresent newP() {
        return new BasePresent();
    }


    public static void lunch(Activity act) {
        Intent intent = new Intent(act, InputEditActivity.class);
        act.startActivity(intent);
    }

    @Override
    public boolean isNotWorkConnect() {
        return false;
    }
}
